package com.hnguigu.controller;


import com.hnguigu.pojo.Users;
import com.hnguigu.service.AccService;
import com.hnguigu.service.Impl.AccServaiceImpl;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/user")
public class UserLoginController {
   @Autowired
   AccService accServaice;
    @RequestMapping("/login")
    public String UrlLogin(String user, String psd){
        //先进控制层
        try {
            System.out.println("账号"+user+"密码"+psd);
            Subject subject = SecurityUtils.getSubject();
            UsernamePasswordToken token = new UsernamePasswordToken(user,psd);
            subject.login(token);
        }catch (Exception e){
            System.out.println("账号或密码错误");
            e.printStackTrace();
            return "/login.jsp";
        }
        return "/zhuye.jsp";
    }
    @RequestMapping("/t1")
    public String t1(){

            accServaice.t1();
        return "/zhuye.jsp";
    }
    @RequestMapping("/t2")
    public String t2(){

            accServaice.t2();

        return "/zhuye.jsp";
    }
    @GetMapping("/del")
    public  String t3(){

        accServaice.t3();
        return "/zhuye.jsp";
    }
    @GetMapping("/find")
    public  String t4(){
            accServaice.t4();
        return "/zhuye.jsp";
    }

}
